package ezxpns.util;

import java.util.*;

public class CommandGroup implements Copyable<CommandGroup>
{
	// Does not make deep copies of added commands!
	private ArrayList<Command<?>> commands;
	public CommandGroup()
	{
		commands=new ArrayList<Command<?>>();
	}
	public CommandGroup(Command<?> action)
	{
		commands=new ArrayList<Command<?>>();
		add(action);
	}
	public void add(Command<?> action)
	{
		commands.add(action);
	}
	public void add(CommandGroup cmdGroup)
	{
		for(int a=0;a<cmdGroup.size();a++) commands.add(cmdGroup.get(a));
	}
	public Command<?> get(int n)
	{
		return commands.get(n);
	}
	public void set(int n,Command<?> action)
	{
		commands.set(n,action);
	}
	public int size()
	{
		return commands.size();
	}
	public CommandGroup copy()
	{
		CommandGroup copy=new CommandGroup();
		for(int a=0;a<commands.size();a++) copy.add(commands.get(a).copy());
		return copy;
	}
}
